package com.itlaoqi.rabbitmq.topic;

import com.itlaoqi.rabbitmq.utils.RabbitConstant;
import com.itlaoqi.rabbitmq.utils.RabbitUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;


public class WeatherBureau {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection =  RabbitUtils.getConnection();
        Map<String,String> areas = new LinkedHashMap<String,String>();
        areas.put("china.hebei.shijianzhuang.20991011","中国河北石家庄20991011天气");
        areas.put("china.shandong.qingdao.20991011","中国山东青岛20991011天气");
        areas.put("china.henna.zhengzhou.20991011","中国河南郑州20991011天气");
        areas.put("us.cal.la.20991011","美国加州洛杉矶20991011天气");

        areas.put("china.hebei.shijianzhuang.20991012","中国河北石家庄20991012天气");
        areas.put("china.shandong.qingdao.20991012","中国山东青岛20991012天气");
        areas.put("china.henna.zhengzhou.20991012","中国河南郑州20991012天气");
        areas.put("us.cal.la.20991012","美国加州洛杉矶20991012天气");

        Channel channel = connection.createChannel();
        for (Map.Entry<String,String> area: areas.entrySet()) {
            channel.basicPublish(RabbitConstant.EXCHANGE_WEATHER_TOPIC,area.getKey(),null,area.getValue().getBytes());
        }
        channel.close();
        connection.close();
    }
}
